package cn.springcloud.fix.common.log.listener;

import cn.springcloud.fix.common.core.base.R;
import cn.springcloud.fix.common.log.event.SysOpLogEvent;
import cn.springcloud.fix.common.log.event.SysLoginInfoEvent;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

/**
 * 异步监听日志事件
 */
@Slf4j
public class LogEventListener {

//    @Autowired
//    private RemoteLogService remoteLogService;

    /*@Async
    @Order
    @EventListener(SysOpLogEvent.class)
    public void saveSysLog(SysOpLogEvent event) {
        SysOperateLogRequest sysOpLogRequest = (SysOperateLogRequest) event.getSource();
        R<Object> res = remoteLogService.insertOpLog(sysOpLogRequest);
        log.info("调用远程日志服务：{}", JSON.toJSONString(res));
    }

    @Async
    @Order
    @EventListener(SysLoginInfoEvent.class)
    public void listenLoginInfo(SysLoginInfoEvent event) {
        SysLoginLogRequest request = (SysLoginLogRequest) event.getSource();
        R<Object> res = remoteLogService.insertLoginLog(request);
        log.info("调用远程日志服务：{}", JSON.toJSONString(res));
    }*/
}
